//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.neurosky.thinkgear;

import java.util.ArrayList;
import java.util.List;

public class HeartRateAcceleration {
    private long a = System.currentTimeMillis();
    private List b = new ArrayList();
    private int c;
    private int d = 0;
    private int e = 0;
    private int f;
    private int[] g = new int[]{-1, -1};
    private int[] h = new int[2];

    public HeartRateAcceleration() {
        this.f = 10000;
    }

    public HeartRateAcceleration(int var1) {
        this.f = var1 * 1000;
    }

    public int[] getAcceleration(int var1, byte var2) {
        if(var2 != 200) {
            this.e = 0;
            this.b.clear();
            this.a = System.currentTimeMillis();
            return this.g;
        } else {
            this.b.add(Integer.valueOf(var1));
            if(System.currentTimeMillis() - this.a < (long)this.f) {
                return this.g;
            } else {
                ++this.e;

                for(var1 = 0; var1 < this.b.size(); ++var1) {
                    this.c += ((Integer)this.b.get(var1)).intValue();
                }

                this.c = (int)((double)this.c / (double)this.b.size());
                this.h[0] = this.c;
                if(this.e == 1) {
                    this.h[1] = 0;
                } else {
                    this.h[1] = this.c - this.d;
                }

                this.d = this.c;
                this.b.clear();
                this.a = System.currentTimeMillis();
                return this.h;
            }
        }
    }
}
